<!-- 添加流水 -->
<template>
	<view class='addmoney'>
		<view class="input-view">
			<textarea   maxlength=1000 style="height:105upx;width: 700upx; rows:2" class="input" type="text" placeholder="使用详情" name="datails" v-model="details"/>
		</view>
		<view class="input-view">
			<input class="input" type="text" placeholder="使用金额" name="money" v-model="money"/>
		</view>
		<view class="input-view">
			<view class="label-view">
				<text class="time">使用时间</text>
			<view><lyzml-datepicker ref="lyzmlDatePicker" :config="datePickerConfig"  @onDateChange="chooseDate"  v-model="time"></lyzml-datepicker></view>
			
			</view>
		</view>
		<view class="input-views">
			<view class="label-view">
			<textarea   maxlength=1000 style="width: 700upx; rows:1"type="text" placeholder="备注" name="remark" v-model="remark"/>
			</view>
		</view>
		<view class="button-view">
			<button type="primary" style="position: absolute;bottom: 10upx;" hover-class="hover" formType="submit" @click="addmoney">提交</button>
		</view>
	</view>
</template>

<script>
	import lyzmlDatePicker from '../../components/lyzml-datepicker/lyzml-datepicker.vue'
	export default {
		components:{lyzmlDatePicker},
		computed: {
			datePickerConfig: function() {
				let retObj = {
					yearsBefore: 15,
					yearsAfter: 0,
					initType: "ymd",
					initDate:""
				};
				return retObj;
			}
		},
		data() {
			
			return {
			'details':"",
			'money':"",
			'time':"",
			'remark':""	
			}
		},
		methods: {
			// 添加流水
			addmoney() {
				
				uni.request({
					url:this.$serverUrl + '/app/hospital/fundRecord/save', //仅为示例，并非真实接口地址。
				    data: {
						'details':this.details,
						'money':this.money,
						'time':this.time,
						'remark':this.remark,
						'createTime':this.useDate
				    },
					method:"POST",
					header:{
						'token': uni.getStorageSync('token'),//登录相关以外的接口需要
						'content-type': "application/json",
						'content-type': "application/x-www-form-urlencoded"
					}, 
					
				    success: (res) => {
						console.log(JSON.stringify(res));
						uni.switchTab({
							url:'./manage'
						})
					 }
			   });
			},
			//获取使用时间
			chooseDate(e) {
				this.useDate= e.value;
				console.log(this.useDate);
			},
			setInitDate(){
				 this.$refs.lyzmlDatePicker.initDate("2020-03-13");
			}
		}
	}
</script>

<style>
.addmoney{
	display: block;
}
.input-view {
	flex-direction: column;
	display: flex;
	width:100%;
	height:105upx;
	border-bottom-style: solid;
	border-bottom-width: 1upx;
	border-bottom-color: #ddd;
	background-color: #fff;
	flex-direction: row;
	width: 700upx;
	padding: 30upx 30upx;
	margin: 10upx;
	font-size: 20upx;
}
.time{
	font-size: 30upx;
	color: #808090;
}
.input-views{
	width:700upx;
	display: flex;
	height: 700upx;
	flex-direction: row;
	padding: 30upx 30upx;
	margin: 10upx;
}
.button-view {
	width: 750upx;
	margin-bottom: 20upx;
	padding: 0 20upx;
	box-sizing: border-box;
	flex-direction: column;
}

button {
	width: 710upx;
	height: 80upx;
	line-height: 80upx;
	text-align: center;
	font-size: 38upx;
	border-radius: 50upx;
	
}

button.submit {
	
}

</style>